import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import DefaultLayout from '@/layouts/DefaultLayout.vue'

// 路由配置
const routes: RouteRecordRaw[] = [
  // 主布局
  {
    path: '/',
    component: DefaultLayout,
    redirect: '/dashboard',
    children: [
      // 工作台
      {
        path: '/dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: '工作台'
        }
      },
      // 健康档案
      {
        path: '/health/archive',
        name: 'HealthArchive',
        component: () => import('@/views/health/archive/index.vue'),
        meta: {
          title: '健康档案'
        }
      },
      // 体检报告
      {
        path: '/health/report',
        name: 'HealthReport',
        component: () => import('@/views/health/report/index.vue'),
        meta: {
          title: '体检报告'
        }
      },
      // 健康指标
      {
        path: '/health/indicator',
        name: 'HealthIndicator',
        component: () => import('@/views/health/indicator/index.vue'),
        meta: {
          title: '健康指标'
        }
      }
    ]
  },
  // 404页面
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound',
    component: () => import('@/views/error/404.vue'),
    meta: {
      title: '页面不存在'
    }
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
